package oo

import (
	"math/rand"
	"regexp"
	"strconv"
	"time"
)

type Number struct {
}

func (o *Number) GenRandom(length int) string {
	random := ""
	for i := 0; i < length; i++ {
		random += strconv.Itoa(rand.New(rand.NewSource(time.Now().UnixNano())).Intn(10))
	}

	return random
}

func (o *Number) IsInt(s string) bool {
	return regexp.MustCompile("^(?:[-+]?(?:0|[1-9][0-9]*))$").MatchString(s)
}

func (o *Number) ToInt(s string) int {
	num, _ := strconv.Atoi(s)
	return num
}

func (o *Number) ToInt64(s string) int64 {
	num, _ := strconv.ParseInt(s, 10, 64)
	return num
}
